package com.hwadee.ems.domain.vo;

import java.time.LocalDate;
import java.math.BigDecimal;

import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.AllArgsConstructor;

import com.fasterxml.jackson.annotation.JsonIgnore;

import com.hwadee.ems.domain.po.Textbook;
import com.hwadee.ems.service.IClassService;
import com.hwadee.ems.service.ICourseService;
import com.hwadee.ems.service.impl.ClassServiceImpl;
import com.hwadee.ems.service.impl.CourseServiceImpl;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class TextbookVO {

    @JsonIgnore
    private ICourseService courseService = CourseServiceImpl.getInstance();

    @JsonIgnore
    private IClassService classService = ClassServiceImpl.getInstance();

    public TextbookVO(Textbook textbook) {
        this.id = textbook.getId();
        this.courseId = textbook.getCourseId();
        this.courseName = courseService.getById(this.courseId).getName();
        this.classId = textbook.getClassId();
        this.className = classService.getById(this.classId).getName();
        this.isbn = textbook.getIsbn();
        this.name = textbook.getName();
        this.publisher = textbook.getPublisher();
        this.author = textbook.getAuthor();
        this.price = textbook.getPrice();
        this.publishDate = textbook.getPublishDate();
    }

    /**
     * 教材编号
     */
    private Long id;

    /**
     * 课程编号 references course(id) for (name)
     */
    private Long courseId;

    /**
     * 课程名称
     */
    private String courseName;

    /**
     * 使用教材的班级编号 references class(id) for (name)
     */
    private Long classId;

    /**
     * 使用教材的班级名称
     */
    private String className;

    /**
     * 标准书号
     */
    private String isbn;

    /**
     * 教材名称
     */
    private String name;

    /**
     * 出版社
     */
    private String publisher;

    /**
     * 编者
     */
    private String author;

    /**
     * 估价
     */
    private BigDecimal price;

    /**
     * 发布时间
     */
    private LocalDate publishDate;
    
}
